#include <stdio.h> 
#include <string.h>
#include <stdlib.h>

#ifdef _WIN32
	#include <windows.h>
	#define timeSleep Sleep
	#define TIME 5000
	#define EXT system("cls");
	void openWeb(char *url)
	{
		ShellExecute(NULL,"open",url,NULL,NULL,SW_SHOWNORMAL);
	}
#elif __APPLE__
	#include <unistd.h>
	#define timeSleep sleep
	#define TIME 5
	#define EXT system("clear");
	void openWeb(char *url)
	{
		char shell[10000] = "open \"";
		strcat(shell, url);
		strcat(shell, "\"");
		system(shell);
	}
#elif __linux__ || __linux
	#include <unistd.h>
	#define timeSleep sleep
	#define TIME 5
	#define EXT system("clear");
	void openWeb(char *url)
	{
		char shell[10000] = "firefox \"";
		strcat(shell, url);
		strcat(shell, "\"");
		system(shell);
	}
#endif
	
int main()
{
	#ifdef _WIN32
	system("title Nuist Websites");
	system("color 0a");
	system("mode 100,40");
	system("cls");
	#elif __linux__ || __linux
	system("clear");
	#elif __APPLE__
	system("clear");
	#endif
	char *choice = malloc(3);
	printf("\t************** 南京信息工程大学网页启动器 V 1.0.0 *******************\n\n");
	printf("\t[ 1] 学校主页\t[ 2] vpn界面\t[ 3] 信息门户\t[ 4] 句酷批改网\n\n");
	printf("\t[ 5] TSOJ\t[6] 奥蓝系统\t[ 7] 学分制系统\t[ 8] 新视野平台\n\n");
	printf("\t[ 9] 新理念平台\t[10] 创新学分\t[11] 实验教学\t[12] 毕设论文\n\n");
	printf("\t[13] 体育部选课\t[14] 我的图书馆\t[15] 线上大厅\t[16] 教育在线\n\n");
	printf("\t[17] 教师主页\t[18] 个人邮箱\t[19] 心理健康\t[20] 校长办公室\n\n");
	printf("\t[21] 用户反馈 (给编写代码的人)\t[22] 退出(exit)\n");
	printf("\n\n\t\t\t校长邮箱为:ldxx@nuist.edu.cn\n\n");
	printf("\n\t***** 有问题请加我好友私聊我或选第21项给我发邮件 QQ:269465508 *****\n\n");
	printf("\n\t请输入您的选择(数字, 无需前面加0) :\t");
	scanf("%s", choice);
	while (1)
	{
		if(strcmp(choice, "1") == 0)
		{
			openWeb("https://www.nuist.edu.cn/");
			main();
		} else if (strcmp(choice, "2") == 0)
		{
			openWeb("https://client.vpn.nuist.edu.cn/client/#/login");
			main();
		} else if (strcmp(choice, "3") == 0)
		{
			openWeb("http://my.nuist.edu.cn/");
			main();
		} else if(strcmp(choice, "4") == 0)
		{
			openWeb("https://www.pigai.org/");
			main();
		} else if (strcmp(choice, "5") == 0)
		{
			openWeb("https://acm.nuist.edu.cn/");
			main();
		} else if (strcmp(choice, "6") == 0)
		{
			openWeb("http://stu.nuist.edu.cn/login.aspx");
			main();
		} else if (strcmp(choice, "7") == 0)
		{
			openWeb("http://wlkt.nuist.edu.cn/");
			main();
		} else if (strcmp(choice, "8") == 0)
		{
			openWeb("http://nsce.unipus.cn/index.php");
			main();
		} else if (strcmp(choice, "9") == 0)
		{
			openWeb("http://202.195.230.218:88/npels/");
			main();
		} else if (strcmp(choice, "10") == 0)
		{
			openWeb("http://sjjx.nuist.edu.cn/cxxf/index.aspx");
			main();
		} else if (strcmp(choice, "11") == 0)
		{
			openWeb("http://sjjx.nuist.edu.cn/syjx/index.aspx");
			main();
		} else if (strcmp(choice, "12") == 0)
		{
			openWeb("http://sjjx.nuist.edu.cn/bysj/index.aspx");
			main();
		} else if (strcmp(choice, "13") == 0)
		{
			openWeb("http://tyb.nuist.edu.cn/");
			main();
		} else if (strcmp(choice, "14") == 0)
		{
			openWeb("http://lib2.nuist.edu.cn/reader/login.php");
			main();
		} else if (strcmp(choice, "15") == 0)
		{
			openWeb("http://e-office.nuist.edu.cn");
			main();
		} else if (strcmp(choice, "16") == 0)
		{
			openWeb("http://nuist.fanya.chaoxing.com/portal");
			main();
		} else if (strcmp(choice, "17") == 0)
		{
			openWeb("http://web2.nuist.edu.cn:8080/jszy/");
			main();
		} else if (strcmp(choice, "18") == 0)
		{
			openWeb("http://mail.nuist.edu.cn/");
			main();
		} else if (strcmp(choice, "19") == 0)
		{
			openWeb("http://202.195.237.188:88/index.asp");
			main();
		} else if (strcmp(choice, "20") == 0)
		{
			openWeb("http://xb.nuist.edu.cn/index.asp");
			main();
		} else if (strcmp(choice, "21") == 0)
		{
			char user[30];
			char null[10];
			gets(null);
			printf("\n\t请输入您的姓名(20内):\t");
			gets(user);
			char info[1000] = "mailto:zyx.1@163.com?subject=关于Nuist Websites的反馈&body=%0A%0A%0A%0A              --来自用户";
			strcat(info, user);
			// printf("%s", info);
			// system("pause");
			openWeb(info);
			fflush(stdout);
			printf("\n\t感谢反馈!!!\n");
			fflush(stdout);
			timeSleep(TIME);
			main();
		} else if (strcmp(choice, "22") == 0 || strcmp(choice, "exit") == 0)
		{
			EXT
			exit(0);
		} else
		{
			printf("\n\t输入有误!");
			fflush(stdout);
			timeSleep(TIME);
			main();
		}
	}
	
}
